import { createStore } from "vuex";

export default createStore({
  state: {
    inputTxt: "",
    template: "",
    basicInfo: [],
  },
  getters: {
    getInputTxt(state) {
      return state.inputTxt;
    },
    getTemplate(state) {
      return state.template;
    },
    getBasicInfo(state) {
      return state.basicInfo;
    },
  },
  mutations: {
    setInputTxt(state, inputTxt) {
      state.inputTxt = inputTxt;
    },
    setTemplate(state, template) {
      state.template = template;
    },
    setBasicInfo(state, basicInfo) {
      state.basicInfo = basicInfo;
    },
    updateBasicInfo(state, { field, value }) {
      const item = state.basicInfo.data.find((item) => item.tagCode === field);
      if (item) {
        item.tagValue = value;
      }
    },
  },
  actions: {},
  modules: {},
});
